import re
def generateBroadcastByIPAndMask(ip,mask):
    ipList = [int(i) for i in ip.split(".")]
    maskList = mask.split(".")
    res = "".join([str(bin(int(i)))[2:].rjust(8,"0") for i in maskList])
    res = "".join([str((int(i)+1)%2) for i in res])
    res = re.findall(r'.{8}',res)
    res = [int("0b"+i,2) for i in res]
    res = [str(i|j) for i,j in zip(ipList,res)]
    res = ".".join(res)
    return res

if __name__ == "__main__":
    res = generateBroadcastByIPAndMask("192.168.1.1","255.255.192.0")
    print(res)
